package com.example.service.impl;

import com.example.mapper.assemblyEquipmentMapp;
import com.example.pojo.assemblyEquipmentPojo;
import com.example.pojo.faultHistoryPojo;
import com.example.service.assemblyEquipmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * ClassName:assemblyEquipmentImpl
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/9/28 19:55
 * @Version 1.0
 */
@Service
@Slf4j
public class assemblyEquipmentImpl implements assemblyEquipmentService {
    @Autowired
    private assemblyEquipmentMapp assemblyEquipmentMapp;
    //在主表中插入一行数据
    public void insertOne(assemblyEquipmentPojo assemblyEquipmentPojo){
        //组合修改时间
        assemblyEquipmentPojo.setUpdateTime(LocalDateTime.now());
        assemblyEquipmentPojo.setEstablishTime(LocalDateTime.now());
        assemblyEquipmentMapp.insertOne(assemblyEquipmentPojo);
    }
    //根据两个字段查询出大表数据
    public List<assemblyEquipmentPojo> inquiryByTowFiled(Map<String, Object> objectMap){
        String firstFiledName=(String) objectMap.get("firstFiledName");
        String firstFiledVal=(String) objectMap.get("firstFiledVal");
        String secondFiledName=(String) objectMap.get("secondFiledName");
        String secondFiledVal=(String) objectMap.get("secondFiledVal");
        List<assemblyEquipmentPojo> list= assemblyEquipmentMapp.inquiryByTowFiled(firstFiledName,firstFiledVal,secondFiledName,secondFiledVal);
        return list;
    }
    //根据id，修改一行数据
    public void editById(assemblyEquipmentPojo assemblyEquipmentPojo){
        assemblyEquipmentPojo.setUpdateTime(LocalDateTime.now());
        assemblyEquipmentMapp.editById(assemblyEquipmentPojo);
    }
    //根据传来的数据，修改一个字段，根据id修改
    public void EditOneById(Map<String, Object> map){
        Integer id=(Integer) map.get("id");
        String filedName=(String) map.get("filedName");
        String filedVal=(String) map.get("filedVal");
        assemblyEquipmentMapp.EditOneById(id,filedName,filedVal);
    }
    //对设备问题插入一行数据
    public void assemblyEquipmentFaultHistoryInsert(faultHistoryPojo faultHistoryPojo){
        //组合创建日期和修改日期
        faultHistoryPojo.setEstablishTime(LocalDateTime.now());
        faultHistoryPojo.setUpdateTime(LocalDateTime.now());
        assemblyEquipmentMapp.assemblyEquipmentFaultHistoryInsert(faultHistoryPojo);
    }
    //设备人员到位了，要处理问题，进行到位时间记录，筛选出本序还没有人处理的问题
    public List<faultHistoryPojo> assemblyEquipmentFaultHistoryFirstReach(Map<String, Object> map){
        String op=(String) map.get("op");
        List<faultHistoryPojo> faultHistoryPojos=assemblyEquipmentMapp.assemblyEquipmentFaultHistoryFirstReach(op);
        return faultHistoryPojos;
    }
}
